package com.sdx.console.spread.service;

import com.ibeetl.admin.core.service.BaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.sdx.console.spread.dao.SpreadChannelDao;
import com.sdx.console.spread.entity.SpreadChannel;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName SpreadChannelService
 * @Description
 * @Author kangbin
 * @Date 2020/3/20 16:04
 */
@Service
@Transactional
public class SpreadChannelService extends BaseService<SpreadChannel> {

    @Resource
    private SpreadChannelDao spreadChannelDao;

    public  PageQuery<SpreadChannel> queryByCondition(PageQuery page) {

        PageQuery ret =  spreadChannelDao.queryByCondition(page);
        queryListAfter(ret.getList());
        return ret;
    }

    public int selectCodeCount(String promoteCode) {
        return spreadChannelDao.selectCodeCount(promoteCode);
    }

    public void batchDelPromoteRecord(List<String> ids){
        try {
            spreadChannelDao.batchDelPromoteRecordByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除推广码失败", e);
        }
    }

}
